package testutils

import (
	"fmt"
	"gitlab.com/adapt-karaoke-project/backend/config"
	"os"
	"strconv"
)

func GetDBConfigFromEnv() (cfg config.DBConfig, err error) {
	port_str := os.Getenv("PORT")
	port_num, err := strconv.Atoi(port_str)
	if err != nil {
		return
	}
	cfg = config.DBConfig{
		Username: os.Getenv("USER"),
		Password: os.Getenv("PASSWORD"),
		Database: os.Getenv("DATABASE"),
		Address:  os.Getenv("ADDRESS"),
		Port:     uint16(port_num),
	}
	fmt.Printf("%+v\n", cfg)
	return
}
